|
|
|
|
|
|
|
coordinate systems. You must convert the control's coordinate system into that of its parent, then into that of its grandparent, and so forth until you have converted the coordinates into the form's coordinate system. You must also be aware that parts of the control may be hidden because it lies outside the visible area of one of its containers. |
|
|
|
|
|
|
|
|
Fourth, the fonts available on the printer may not be the same as those on your monitor. In that case, the printed result will not exactly match the print preview. |
|
|
|
|
|
|
|
|
Finally, even if you get all of these details perfectly correct, the result may still not be exactly what you need. If text is hidden in a scrolled text box, you may want to enlarge the printed output to show all of the text. While there may not be enough room on the screen, there may be plenty of room on the printout. |
|
|
|
|
|
|
|
|
Example program HiRes, shown in Figure 5.8, use a subroutine named HiResPrint to display a high-resolution version of the form. |
|
|
|
|
|
|
|
|
Subroutine HiResPrint takes as a parameter a reference to the object on which it should draw the image. The program uses this parameter to provide a print preview. It draws the preview image into a hidden picture box and then uses PaintPicture to display the preview at different scales. |
|
|
|
|
|
|
|
|
Program HiRes uses techniques described earlier in this chapter to create printouts at either the form's current size or enlarged to fill the printout. When the form's image is enlarged, the program allows text inside controls to expand to fill the available space. For example, suppose a text box contains so much text that it is not all visible at once on the form. When the program prints the form enlarged, it allows the text box to use the extra available space to display more text. |
|
|
|
|
|
|
|
|
Figure 5.8
Example program HiRes displays previews at multiple scales
and produces high-resolution printouts. |
|
|
|
|
|